Test Series - java script

Test Number 39/92

Q: How many node types are there in total?
A. 11
B. 12
C. 13
D. 14
Solution: There are total of 12 node types. The nodeType property returns the node type, as a number, of the specified node.
Q: What is the purpose of the Node object property ownerDocument?
A. Returns the root element
B. Returns the last element
C. Returns the parent node
D. Returns the immediate node
Solution: The ownerDocument property returns the owner document of a node, as a Document object. It returns the root element for a node.
Q: Which of the following Node object property returns the local part of the name of a node?
A. lastName
B. localName
C. firstName
D. objectname
Solution: The Node object property localName Returns the local part of the name of a node. If the selected node is not an element or attribute, this property returns NULL.
Q: What is the property textContent?
A. Sets the textual content of a node
B. Returns the textual content of a node
C. Sets & Returns the textual content of a node
D. Modifies texual content
Solution: The property textContent sets or returns the textual content of a node and its descendants. If you set the textContent property, any child nodes are removed and replaced by a single Text node containing the specified string.
Q: How many Node object methods are available?
A. 18
B. 16
C. 20
D. 21
Solution: The Node object represents a single node in the document tree. There are totally 18 node object methods.
Q: Which of the following Node object property returns the node immediately before a node?
A. previousSibling
B. textContent
C. index
D. localName
Solution: The node object property previousSibling returns the node immediately before a node. The returned node is returned as a Node object.
Q: What is the purpose of the method getUserData(key)?
A. Returns the associated object
B. Gets the user data
C. Returns the user data
D. Gets the user key
Solution: The method getUserData(key) returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.
Q: How to test if two nodes are equal?
A. isEqualNode()
B. equal()
C. ==
D. equalto()
Solution: The method isEqualNode() is used to test if two nodes are equal. Two nodes are equal when they have the same type, defining characteristics (for elements, this would be their ID, number of children, and so forth), its attributes match, and so on.
Q: How to associate an object to a key on a node?
A. getUserData()
B. cloneNode()
C. setUserData(key,data,handler)
D. clonedata()
Solution: The Node.setUserData() method allows a user to attach (or remove) data to an element, without needing to modify the DOM. This method is used to associate an object to a key on a node.
Q: Which method is used to compare the placement of two nodes in the DOM hierarchy (document)?
A. compareDocumentPosition()
B. cloneNode()
C. getUserData()
D. getFeature()
Solution: The compareDocumentPosition() method is used to compare the placement of two nodes in the DOM hierarchy (document). The return value is an integer value whose bits represent the calling Node’s relationship to otherNode within the Document.

You Have Score    /10